layui.define(["table", "form", "admin"], function (exports) {
    var $ = layui.$,
        table = layui.table;

    table.render({
        elem: "#LAY-home-channel",
        url: '/guild/regsource/stat',
        cols: [[
            { field: 'source_key', width: 180, title: '渠道标识', fixed: true }
            , { field: 'source_name', title: '渠道名称' }
            , { field: 'url', title: '渠道域名' }
            // , { field: 'ips', title: 'IP访问量' }
            , {
                field: 'down_total', title: '下载数量', templet: function (d) {
                    return d.appdownload ? d.appdownload.total : 0;
                }
            },
            { field: 'reg_count', width: 180, title: '注册人数' }
            , {
                field: '', title: '设备', templet: function (d) {
                    switch (d.device) {
                        case 1:
                            return "<span style='color:#009688'>安卓</span>";
                        case 2:
                            return "<span style='color:#1E9FFF'>苹果</span>";
                        case 3:
                            return "<span style='color:#FFB800'>PC端</span>";
                    }
                    return '';
                }
            }

        ],
        ],
        page: true,
        limit: 20,
        height: "full-140",
        text: {
            none: '暂无数据'
        },
        even: true,
    });

    // 直播历史
    table.render({
        elem: '#LAY-home-stat',
        url: '/guild/regsource/date_stat',
        cols: [[
            { field: 'date', width: 180, title: '日期', fixed: true },
            { field: 'source_key', width: 180, title: '渠道标识', fixed: true }
            , { field: 'source_name', title: '渠道名称' }
            , { field: 'url', title: '渠道域名' }
            // , { field: 'ips', title: 'IP访问量' }
            , {
                field: 'down_total', title: '下载数量', templet: function (d) {
                    return d.appdownload ? d.appdownload.total : 0;
                }
            },
            { field: 'reg_count', width: 180, title: '注册人数' }
            , {
                field: '', title: '设备', templet: function (d) {
                    switch (d.device) {
                        case 1:
                            return "<span style='color:#009688'>安卓</span>";
                        case 2:
                            return "<span style='color:#1E9FFF'>苹果</span>";
                        case 3:
                            return "<span style='color:#FFB800'>PC端</span>";
                    }
                    return '';
                }
            }
        ]]
        , page: true
        , limit: 20
        , height: 'full-140'
        , text: '对不起，加载出现异常！'
        , even: true
    });

    exports("guild/home", {});
});
